from pathlib import Path

path = Path('pi_digits.txt')
contents = path.read_text()
print(contents)

lines = contents.splitlines()
pi_string = ''
for line in lines:
    pi_string += line.strip()

if pi_string:
    print(pi_string)

# Writing new content to the file
write_contents = '3.1415926535\n8979323846\n2643383279'

row = 100000
while row > 0:
    row -= 1
    write_contents += '\nrow num : ' + str(row)

path.write_text(write_contents)